<template>
	<view>
		<view class="bg-f has-pd-20">
			<text>我的团队</text>
			<button type="primary" plain="true" size="mini" @tap="income" class="has-floatr">领取</button>
		</view>
		<view class="bg-f has-pd-20 has-mgtb-10 is-team">
			<view class="is-team-li is-center">
				<view class="is-blod is-size-20">
					<text>{{results}}</text><text>万</text>
				</view>
				<view class="is-grey is-size-14">
					<text>今日团队业绩</text>
				</view>
			</view>
			<view class="is-team-li is-center">
				<view class="is-blod is-size-20">
					<text>{{branch_all}}</text>/<text>{{branch_lock}}</text>
				</view>
				<view class="is-grey is-size-14">
					<text>团队人数/激活</text>
				</view>
			</view>
			<view class="is-team-li is-center">
				<view class="is-blod is-size-20">
					<text>{{today_branch_all}}</text>/<text>{{today_branch_lock}}</text>
				</view>
				<view class="is-grey is-size-14">
					<text>今日新增/激活</text>
				</view>
			</view>
		</view>
		<view class="bg-f has-pdlr-20">
			<view class="height-50">
				<navigator url="./my_branch">
					<text>我的下级</text>
					<image src="../../static/img/common/right_ico_grey.png" mode="" class="right_ico has-floatr"></image>					
				</navigator>
			</view>
			<view class="height-50">
				<navigator url="./my_income">
				<text>业绩报表</text>
					<image src="../../static/img/common/right_ico_grey.png" mode="" class="right_ico has-floatr"></image>
				</navigator>
			</view>
			<view class="height-50">
				<navigator url="./return_form">
					<text>返佣阶梯表</text>
					<image src="../../static/img/common/right_ico_grey.png" mode="" class="right_ico has-floatr"></image>
				</navigator>
			</view>
		</view>
	</view>
</template>

<script>
	var _self;
	export default{
		data(){
			return {
				results:0,
				branch_all:0,
				branch_lock:0,
				today_branch_all:0,
				today_branch_lock:0
			}
		},
		onLoad() {
			_self = this;
			let info = this.service.getfox();
			if(info[0]){
				this.foxtoken = info[0]['foxtoken'];
				uni.request({
					url: this.service.FOX_URL + 'diamond/get_myteam_home',
					method:'POST',
					data: {
						user_key:this.foxtoken
					},
					dataType:'json',
					header:{
						'content-type':'application/x-www-form-urlencoded'
					},
					success: res => {    
						var foxmsg = res.data;
						// console.log(foxmsg)
						if (foxmsg.code == 200) { 
							this.results=foxmsg.data.list.results;
							this.branch_all=foxmsg.data.list.branch_all;
							this.branch_lock=foxmsg.data.list.branch_lock;
							this.today_branch_all=foxmsg.data.list.today_branch_all;
							this.today_branch_lock=foxmsg.data.list.today_branch_lock;
						}
					}                    
				});
			}else{
				uni.reLaunch({
					url:'../logon/login'
				})
			}
		},
		methods:{
			income(){
				uni.navigateTo({
					url:'./agent_income'
				})
			}
		}
	}
</script>

<style>
	.is-team{
		height: 120rpx;
		line-height: 60rpx;
	}
	.is-team-li{
		width: 33%;
		float: left;
	}
	.height-50{
		height: 100rpx;
		line-height: 100rpx;
		border-bottom: 1px solid #E5E5E5;
	}
	.right_ico{
		width: 40rpx;
		height: 40rpx;
		margin-top:40rpx;
	}
</style>
